<?php 
   require_once('../mod_config.php');
   require_once('../category/config.php');
   class Playlist{
      
      public static function addPla($pla_name,$cat_id){
         if($pla_name != ''){
            $sql_insert = "INSERT INTO
                                 playlist(pla_name,
                                          cat_id)
                                 VALUES('" . $pla_name . "'," . $cat_id . ")";
            $db_exe = new db_execute($sql_insert);
            unset($db_exe);
         }
      }
      
      public static function updatePla($pla_name,$cat_id,$pla_id){
         if($pla_id > 0){
            $sql_update = "UPDATE
                                 playlist
                              SET
                                 pla_name ='" . $pla_name . "',
                                 cat_id =" . $cat_id . " 
                              WHERE
                                 pla_id = " . $pla_id;
            $db_update = new db_execute($sql_update);
            unset($db_update);
         }
      }
      public static function getListPla($limit = ''){
         if($limit != ''){
            $limit = ' LIMIT ' . $limit;
         }
         $arr = array();
         $sql_select = "SELECT pla_id,
                              pla_name,
                              playlist.cat_id,
                              cat_name
                        FROM
                              playlist
                        INNER JOIN
                              category
                        ON
                              playlist.cat_id = category.cat_id
                        " . $limit;
         $db_select = new db_query($sql_select);
         $arr = $db_select->resultArray('pla_id');
         unset($db_select);
         return $arr;
      }
      
      public static function getInfo($pla_id){
         $arr = array();
         if($pla_id > 0){
            $sql_select = "SELECT pla_id,
                              pla_name,
                              playlist.cat_id,
                              cat_name
                        FROM
                              playlist
                        INNER JOIN
                              category
                        ON
                              playlist.cat_id = category.cat_id
                        WHERE
                              pla_id = ".$pla_id."
                        LIMIT 1";
            $db_select = new db_query($sql_select);
            $arr = $db_select->resultArray();
            unset($db_select);
         }
         return $arr;
      }
      
      public static function delPla($pla_id){
         if($pla_id > 0){
            $db_del = new db_execute("DELETE FROM playlist WHERE pla_id =" . $pla_id);
         }
      }
   }
?>